Carbon


StringOrder

Header: StringCompare.h Carbon status: Supported

Compares two Pascal strings, taking into account the script system and language for each of the strings.

SInt16 StringOrder (
    ConstStr255Param aStr, 
    ConstStr255Param bStr, 
    ScriptCode aScript, 
    ScriptCode bScript, 
    LangCode aLang, 
    LangCode bLang
);
aStr

One of the Pascal strings to be compared.

bStr

The other Pascal string to be compared.

aScript

The script code for the second string.

bScript

The script code for the first string.

aLang

The language code for the first string.

bLang

The language code for the second string.

function result

–1 if the first string is less than the second string, 0 if the first string is equal to the second string, and 1 if the first string is greater than the second string. The ordering of script and language codes, which is based on information in the script-sorting resource, is considered in determining the relationship of the two strings.0

DISCUSSION

This function takes both primary and secondary sorting orders into consideration and returns a value that indicates whether the first string is less than, equal to, or greater than the second string.

“Implicit Language Codes” are listed in the Constants section. Most applications specify the language code scriptCurLang for both the aLang and bLang values.

StringOrder first calls ScriptOrder; if the result of ScriptOrder is not 0 (that is, if the strings use different scripts), StringOrder returns the same result.

StringOrder next calls LanguageOrder; if the result of LanguageOrder is not 0 (that is, if the strings use different languages), StringOrder returns the same result.

At this point, StringOrder has two strings that are in the same script and language, so it compares them by using the sorting rules for that script and language, applying both the primary and secondary sorting orders. If that script is not installed and enabled, it uses the sorting rules specified by the system script or the font script, depending on the state of the international resources selection flag.

The StringOrder function is primarily used to insert Pascal strings in a sorted list; for sorting, rather than using this function, it may be faster to sort first by script and language by using the ScriptOrder and LanguageOrder functions, and then to call the CompareString function, to sort strings within a script or language group.

SPECIAL CONSIDERATIONS

StringOrder may move memory; your application should not call this function at interrupt time.

AVAILABILITY

Supported in Carbon. Available in CarbonLib 1.0 and later. Exported by CarbonLib 1.0 and later.


© 2000 Apple Computer, Inc. — (Last Updated 4/14/2000)